#include "TcpServer.hpp"
#include "Dict.hpp"
#include "Command.hpp"
void Usage(std::string proc)
{
    std::cerr << "Usage" << proc << " port" << std::endl;
}

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        exit(USAGE_ERR);
    }

    uint16_t port = std::stoi(argv[1]);

    Enable_Console_Log_Strategy();

    // Dict d;
    // d.LoadDict();
    Command cmd;
    //命令行xshell
    func_t ret = std::bind(&Command::Execute,&cmd,std::placeholders::_1,std::placeholders::_2);
    std::unique_ptr<TcpServer> tsvr = std::make_unique<TcpServer>(port,ret);
    
    // std::unique_ptr<TcpServer> tsvr = std::make_unique<TcpServer>(port, [&cmd](const std::string &command, InetAddr &addr)
    // { return cmd.Execute(command, addr); });
    
    //翻译
    // std::unique_ptr<TcpServer> tsvr = std::make_unique<TcpServer>(port);
    // std::unique_ptr<TcpServer> tsvr = std::make_unique<TcpServer>(port, [&d](const std::string &word, InetAddr &addr)
    // { return d.Translate(word, addr); });

    tsvr->Init();
    tsvr->Run();

    return 0;
}